//package com.qst.crop.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
//import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.service.*;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spi.service.contexts.SecurityContext;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
//
//import java.util.List;
//
//import static com.google.common.collect.Lists.newArrayList;
//
//@Configuration
//@EnableSwagger2
//public class SwaggerConfig extends WebMvcConfigurationSupport {
//
//	private final String adminBasePackage = "com.qst.crop.controller";
//
//	@Bean
//	public Docket createAdminRestApi() {
//		return new Docket(DocumentationType.SWAGGER_2).groupName("XXXX系统").apiInfo(this.apiInfo()).select()
//				.apis(RequestHandlerSelectors.basePackage(adminBasePackage)).paths(PathSelectors.any()).build()
//				.securitySchemes(securitySchemes()).securityContexts(securityContexts());
//	}
//
//	private List<ApiKey> securitySchemes() {
//		return newArrayList(new ApiKey("Authorization", "Authorization", "header"));
//	}
//
//	private List<SecurityContext> securityContexts() {
//		return newArrayList(SecurityContext.builder().securityReferences(defaultAuth())
//				.forPaths(PathSelectors.regex("^(?!auth).*$")).build());
//	}
//
//	List<SecurityReference> defaultAuth() {
//		AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
//		AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
//		authorizationScopes[0] = authorizationScope;
//		return newArrayList(new SecurityReference("Authorization", authorizationScopes));
//	}
//
//	private ApiInfo apiInfo() {
//		return new ApiInfoBuilder().title("XXXX系统API文档接口").contact(new Contact("西安天尚行网络科技有限公司", "", ""))
//				.version("1.0.0").description("XXXX系统API文档接口").build();
//	}
//
//	@Override
//	protected void addResourceHandlers(ResourceHandlerRegistry registry) {
//		// 解决静态资源无法访问
//		registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
//		// 解决swagger无法访问
//		registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
//		// 解决swagger的js文件无法访问
//		registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
//	}
//
//}
